#include<bits/stdc++.h>
using namespace std;
#define int long long

int fun(int n, vector<int> a) {
	sort(a.begin(), a.end());

	int num = 0, idx = n - 1, ans = -1;
	for (int i = a[n - 1]; i >= 0; i--) {
		if (i <= a[idx]) {
			num++;
			idx--;
			ans = max(ans, num * i);
		}
	}
	return ans;
}

signed main() {
	int n, x;
	cin >> n;
	vector<int> a;
	for (int i = 1 ; i <= n; i++) {
		cin >> x;
		a.push_back(x);
	}
	cout << fun(n, a);
	return 0;
}
